package com.ruoyi.web.controller.member;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.member.domain.MemberUser;
import com.ruoyi.member.service.IMemberUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 桃丽丝研究所成员信息Controller
 *
 * @author Marissa
 * @date 2023-12-07
 */
@RestController
@RequestMapping("/member/user")
public class MemberUserController extends BaseController
{
    @Autowired
    private IMemberUserService memberUserService;

    /**
     * 查询桃丽丝研究所成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberUser memberUser)
    {
        startPage();
        List<MemberUser> list = memberUserService.selectMemberUserList(memberUser);
        return getDataTable(list);
    }

    /**
     * 导出桃丽丝研究所成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:user:export')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberUser memberUser)
    {
        List<MemberUser> list = memberUserService.selectMemberUserList(memberUser);
        ExcelUtil<MemberUser> util = new ExcelUtil<MemberUser>(MemberUser.class);
        util.exportExcel(response, list, "桃丽丝研究所成员信息数据");
    }

    /**
     * 获取桃丽丝研究所成员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:query')")
    @GetMapping(value = "/{memberId}")
    public AjaxResult getInfo(@PathVariable("memberId") Long memberId)
    {
        return success(memberUserService.selectMemberUserByMemberId(memberId));
    }

    /**
     * 新增桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:add')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberUser memberUser)
    {
        return toAjax(memberUserService.insertMemberUser(memberUser));
    }

    /**
     * 修改桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:edit')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberUser memberUser)
    {
        return toAjax(memberUserService.updateMemberUser(memberUser));
    }

    /**
     * 删除桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:user:remove')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberIds}")
    public AjaxResult remove(@PathVariable Long[] memberIds)
    {
        return toAjax(memberUserService.deleteMemberUserByMemberIds(memberIds));
    }
}
